﻿<!DOCTYPE html>
<!--隐患排查上报管理编辑-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>

    <style>
        .el-image img {
            width: 150px;
            height: 150px;
        }
        .el-dialog__body {
            height: 100% !important;
        }

        .el-dialog.is-fullscreen {
            overflow: hidden !important;
        }

        body {
            padding-bottom: 10px;
        }

        /*说明：
         由于mystyle.css中162行.el-form-item__content {line-height: normal!important;}导致的
         index.css中.el-form-item--mini .el-form-item__content, .el-form-item--mini .el-form-item__label{    line-height: 28px;}失效
         但出于无法修改样式表的情况，所以在该页面添加以下样式，以保证页面内标题和内容不偏离
        */
        .el-form-item--mini .el-form-item__content,
        .el-form-item--mini .el-form-item__label {
            line-height: 28px !important;
        }
    </style>
    <style>
        ._delete-icon {
            position: absolute;
            right: 5px;
            bottom: 13px;
            cursor: pointer;
            display: none;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak class="popupW100">
        <el-form :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px" size="mini"
                 label-position="right">
            <el-row>
                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item :label="RisksManagement.RiskReport.Discoverer+mark.m" class="inputTextarea">
                                {{Form.yH_StandingBook.discovererText}}
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item :label="'区域'+mark.m" class="inputTextarea">
                                {{Form.areaName}}
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item :label="RisksManagement.RiskReport.RiskLevel+mark.m" class="inputTextarea">
                                {{Form.riskLevelText}}
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item :label="'排查类型'+mark.m" class="inputTextarea">
                                {{Form.standardTypeText}}
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>

                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.RiskReport.OrganizationType+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.yH_StandingBook.organizationType" slot="suffix"
                                               :placeholder="RisksManagement.RiskReport.OrganizationType">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in OrganizationType" :label="item.value"
                                                   :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>


                <el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        {{RisksManagement.RiskReport.DiscoveryTime+mark.m}}
                                    </template>
                                    <el-date-picker slot="suffix" v-model="Form.yH_StandingBook.discoveryTime"
                                                    format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date"
                                                    size="mini" placeholder="选择时间">
                                    </el-date-picker>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>




                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.RiskReport.RiskPosition+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.locationID" slot="suffix"
                                               :placeholder="RisksManagement.RiskReport.RiskPosition">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in RiskPosition" :label="item.jobPlace" :value="item.id">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>


                <el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.RiskReport.RiskType+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.yH_StandingBook.riskType" slot="suffix"
                                               :placeholder="RisksManagement.RiskReport.RiskType">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in RiskType" :label="item.value" :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>


            </el-row>
            <el-row>
                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        {{'整改期限'+mark.m}}
                                    </template>
                                    <el-date-picker slot="suffix" v-model="Form.yH_StandingBook.deadLine"
                                                    format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date"
                                                    size="mini" placeholder="选择时间">
                                    </el-date-picker>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>

            </el-row>
            <el-row>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{RisksManagement.RiskReport.RiskDescription+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.yH_StandingBook.riskDescription"
                                          autocomplete="off"></el-input>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>

            </el-row>
            <el-row>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item label="整改前照片:">
                            <div v-for="src in Form.yH_StandingBook.yH_AttachmentBefore" style="float:left;margin-right:5px;position:relative;"
                                 class="ImgBox">
                                <i class="el-icon-delete _delete-icon" @click="deleteImg(src.attachment)"></i>
                                <!--<img :src="host +src.photoPath" class="avatar" width="150" height="150">-->
                                <el-image style="width: 150px; height: 150px"
                                          class="avatar"
                                          fit="fill"
                                          :src="host + '/api/file/DownLoad?id='+src.attachment"
                                          :preview-src-list="srcList">
                                </el-image>
                            </div>
                            <el-upload class="avatar-uploader" :action="UploadFileApiUrl" name="files"
                                       :show-file-list="false" :on-success="photohandleAvatarSuccess"
                                       :before-upload="beforeAvatarUpload">

                                <i class="el-icon-plus avatar-uploader-icon" style="width: 150px;height: 150px;line-height: 150px; border: 1px solid #ccc;"></i>
                            </el-upload>

                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row type="flex" justify="end">
                <el-form-item>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnCommit}}</el-button>
                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>
    </div>
    <script>
        //图片删除图标
        $(function () {
            $('body').on('mouseenter mouseleave', '.el-image', function (e) {
                if (e.type == 'mouseenter') {
                    $(this).prev("i").show();
                }
                else if (e.type == 'mouseleave') {
                    $(this).prev("i").hover(function () {
                        $(this).show()
                    }).hide()
                }
            })
        })
    </script>
    <script type="text/javascript">

        app = new Vue({
            el: '#app',
            data: {
                //父业传参
                id: '',
                ListItem: ListItem,
                UploadFileApiUrl: API_UPLOADFILE_URL,
                srcList: [],//图片地址集合
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    areaName: '',
                    riskLevelText: '',
                    standardTypeText: '',
                    locationID: '',
                    BeforeRectificationImg: [],
                    yH_StandingBook: {
                        organizationType: '',
                        discoverer: '',
                        discovererText: '',
                        discoveryTime: '',
                        organizationType: '',
                        riskType: '',
                        riskDescription: '',
                        yH_AttachmentBefore:[]
                    }
                },
                OrganizationType: [],
                RiskPosition: [],
                RiskType: [],
                //表单验证
                rules: {

                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            //父页面Form对象
                            var parentForm = parent.app.Form;

                            mythis.Form.result = '异常';
                            //获取父级的父级表中的排查标准类型，真麻烦
                            mythis.Form.yH_StandingBook.inspectType= parentForm.standardType;

                            onSubmitForm(this, '/api/YH_Screening/Report', mythis.Form);
                        } else {
                            //验证失败
                            return false;
                        }
                    });

                },
                getData: function () {
                    getData(this, '/api/YH_Screening/GetDetail?id=' + this.id);
                },

                //位置
                GetRiskPosition: function (type) {
                    var mythis = this;
                    myAjax("get", this, '/api/SysJobPlace/GetJobPlaceList?id=' + mythis.Form.areaID, null
                        , function (response) {
                            console.log('1', response.data);
                            mythis.RiskPosition = response.data;
                        },
                        false);
                },
                beforeAvatarUpload(file) {
                    const isJPG = file.type === 'image/jpeg';
                    const isPNG = file.type === 'image/png';
                    const isLt2M = file.size / 1024 / 1024 < 2;
                    if (!isJPG && !isPNG) {
                        this.$message.error('仅可上传 JPG和PNG 格式!');
                    }
                    if (!isLt2M) {
                        this.$message.error('上传图片大小不能超过 2MB!');
                    }
                    return (isJPG || isPNG) && isLt2M;
                },
                photohandleAvatarSuccess(res, file) {
                    var data = res.data;//成功后的业务数据
                    var fileModel = data[0];//第一个文件对象
                    console.log('fileModel', fileModel)
                    console.log('data', data)
                    if (!this.Form.yH_StandingBook.yH_AttachmentBefore) this.Form.yH_StandingBook.yH_AttachmentBefore = [];
                    this.Form.yH_StandingBook.yH_AttachmentBefore.push({
                        attachment: fileModel.id,
                        attachmentName: fileModel.fileName
                    });

                    //srcList
                    //      : src = "host + '/api/file/DownLoad?'+src.Attachment"
                    console.log(this.Form.yH_StandingBook.yH_AttachmentBefore)

                },
                deleteImg: function (id) {
                    var list = this.Form.yH_StandingBook.yH_AttachmentBefore;
                    this.$confirm(' 是否确认继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(function () {
                    
                        list.forEach(function (v, i) {
                            if (v.attachment + '' === id + '') {
                                list.splice(i, 1);
                            }
                        })
                    }).catch(function () {
                        showMessage("已取消删除!");
                    });
                },
            },
            mounted: function () {
                this.OrganizationType = getDicData('7835');
                this.RiskType = getDicData('095036');
                this.id = getUrlParam("id");
                this.getData();
                this.GetRiskPosition();


                //var xx = {};

                //xx.time = this.Form.DiscoveryTime;

                //this.Form.DiscoveryTime1 = xx.time;
                //this.Form.DiscoveryTime2 = xx.time;
                ////this.Form.DiscoveryTime = '2019-09-09';


                //this.$set(this.Form, "DiscoveryTime", xx.time)


                //console.log('Form.DiscoveryTime', this.Form.DiscoveryTime);

            }
        });
    </script>
</body>

</html>